<?php

namespace Drupal\shusy_team\ViewsController;

use Drupal\shusy_team\ViewsController\handler\field\ShusyTeamEditLinkViewsField;
use Drupal\shusy_team\ViewsController\handler\field\ShusyTeamLevelViewsField;
use Drupal\shusy_team\ViewsController\handler\field\ShusyTeamStatusViewsField;
use Drupal\shusy_team\ViewsController\handler\filter\ShusyTeamLevelViewsFilter;
use Drupal\shusy_team\ViewsController\handler\filter\ShusyTeamStatusViewsFilter;
use EntityDefaultViewsController;


class ShusyTeamViewsController extends EntityDefaultViewsController {

  public function views_data() {
    $data = parent::views_data();
    if (!empty($this->info['base table'])) {
      $table = $this->info['base table'];
      $revision_table = $this->info['revision table'];

      $info = [];

      $info[$table]['edit_link'] = [
        'title' => t('编辑'),
        'help' => t('编辑.'),
        'field' => [
          'handler' => ShusyTeamEditLinkViewsField::class,
        ],
      ];
      $info[$table]['level'] = [
        'title' => '等级信息冗余 1 市场高级顾问 2 市场总监 3 市场部长 4 分红型股东',
        'help' => '等级信息冗余 1 市场高级顾问 2 市场总监 3 市场部长 4 分红型股东',
        'real field' => 'level',
        'field' => [
          'handler' => ShusyTeamLevelViewsField::class,
        ],
        'filter' => [
          'handler' => ShusyTeamLevelViewsFilter::class,
        ],
      ];
      $info[$table]['status'] = [
        'title' => '状态 0 无效 1 有效',
        'help' => '状态 0 无效 1 有效',
        'real field' => 'status',
        'field' => [
          'handler' => ShusyTeamStatusViewsField::class,
        ],
        'filter' => [
          'handler' => ShusyTeamStatusViewsFilter::class,
        ],
      ];
      $info[$revision_table]['level'] = [
        'title' => '等级信息冗余 1 市场高级顾问 2 市场总监 3 市场部长 4 分红型股东',
        'help' => '等级信息冗余 1 市场高级顾问 2 市场总监 3 市场部长 4 分红型股东',
        'real field' => 'level',
        'field' => [
          'handler' => ShusyTeamLevelViewsField::class,
        ],
        'filter' => [
          'handler' => ShusyTeamLevelViewsFilter::class,
        ],
      ];
      $info[$revision_table]['status'] = [
        'title' => '状态 0 无效 1 有效',
        'help' => '状态 0 无效 1 有效',
        'real field' => 'status',
        'field' => [
          'handler' => ShusyTeamStatusViewsField::class,
        ],
        'filter' => [
          'handler' => ShusyTeamStatusViewsFilter::class,
        ],
      ];

      $data = drupal_array_merge_deep($data, $info);
    }
    return $data;
  }
}
